home *** CD-ROM | disk | FTP | other *** search
- #define FlagsNZ(z)\
- flags &=~(ZER+NEG); if (z==0) flags|=ZER; else flags |=z&128
-
- #define ORA(x) a|=ByteAt(x()); FlagsNZ(a)
- #define ASL(x) \
- addr = x();\
- tbyte = ByteAt(addr);\
- flags &=~(CAR+NEG+ZER);\
- if (tbyte&128) flags |= CAR;\
- if (tbyte=tbyte<<1) flags |=tbyte&128; else flags |=ZER;\
- RAM[addr] = tbyte; \
- if (addr==1) \
- if (tbyte!=oldMemoryMap) \
- { \
- oldMemoryMap=tbyte; \
- SetUpMemoryMap(); \
- }
- #define LSR(x) \
- addr=x();\
- tbyte=ByteAt(addr);\
- flags &=~(CAR+NEG+ZER);\
- flags |=tbyte&1;\
- if (tbyte=tbyte>>1); else flags |=ZER;\
- RAM[addr] = tbyte; \
- if (addr==1) \
- if (tbyte!=oldMemoryMap) \
- { \
- oldMemoryMap=tbyte; \
- SetUpMemoryMap(); \
- }
- #define BCL(x) \
- if (flags&x) pc++; \
- else {\
- tbyte=ImmediateByte();\
- pc++;\
- if (tbyte&128) pc-=(tbyte^255)+1; \
- else pc +=tbyte; }
- #define BST(x) \
- if (flags&x) {\
- tbyte=ImmediateByte();\
- pc++;\
- if (tbyte&128) pc-=(tbyte^255)+1;\
- else pc +=tbyte; }\
- else pc++;
- #define CLR(x) flags &=~x;
- #define SET(x) flags |= x;
- #define AND(x) a &= ByteAt(x()); FlagsNZ(a)
- #define BIT(x) \
- tbyte=ByteAt(x());\
- flags &=~(ZER+NEG+OVF);\
- if ((a&tbyte)==0) flags |=ZER;\
- flags |=tbyte&(128+64)
- #define ROL(x) \
- addr=x();\
- tbyte=ByteAt(addr);\
- if (flags&CAR) {\
- if (tbyte&128);\
- else flags &=~CAR;\
- tbyte=(tbyte<<1)|1; }\
- else {\
- if (tbyte&128) flags|=CAR;\
- tbyte=tbyte<<1; }\
- FlagsNZ(tbyte);\
- RAM[addr] = tbyte; \
- if (addr==1) \
- if (tbyte!=oldMemoryMap) \
- { \
- oldMemoryMap=tbyte; \
- SetUpMemoryMap(); \
- }
- #define EOR(x) a^=ByteAt(x());FlagsNZ(a)
- #define ADC(x) \
- addr=ByteAt(x());\
- if (flags&DEC) {\
- addr = bcd2dec[addr]+bcd2dec[a]+((flags&CAR)?1:0);\
- flags &= ~(CAR+OVF+NEG+ZER);\
- if (addr>99) {flags|=CAR+OVF;addr -=100;}\
- if (addr==0) flags|=ZER; else flags |=addr&128;\
- a=dec2bcd[addr];}\
- else {\
- addr += a+((flags&CAR)?1:0);\
- flags &= ~(CAR+OVF+NEG+ZER);\
- if (addr>255) {flags|=OVF+CAR; addr &=255;}\
- if (addr==0) flags|=ZER; else flags |=addr&128;\
- a=addr;}
- #define ROR(x) \
- addr=x(); tbyte=ByteAt(addr);\
- if(flags&CAR){if(tbyte&1); else flags&=~CAR;tbyte=(tbyte>>1)|128;}\
- else{if(tbyte&1) flags|=CAR;tbyte=tbyte>>1;}\
- FlagsNZ(tbyte);\
- RAM[addr] = tbyte; \
- if (addr==1) \
- if (tbyte!=oldMemoryMap) \
- { \
- oldMemoryMap=tbyte; \
- SetUpMemoryMap(); \
- }
- #define STA(x) RAM[addr=x()]=a; \
- if (addr==1) \
- if (a!=oldMemoryMap) \
- { \
- oldMemoryMap=a; \
- SetUpMemoryMap(); \
- }
-
- #define STY(x) RAM[addr=x()]=y;\
- if (addr==1) \
- if (y!=oldMemoryMap) \
- { \
- oldMemoryMap=y; \
- SetUpMemoryMap(); \
- }
-
- #define STX(y) RAM[addr=y()]=x;\
- if (addr==1) \
- if (x!=oldMemoryMap) \
- { \
- oldMemoryMap=x; \
- SetUpMemoryMap(); \
- }
-
- #define CPY(x) \
- tbyte=ByteAt(x()); flags &=~(CAR+ZER+NEG);\
- if (y==tbyte) flags |=CAR+ZER;\
- else if (y>tbyte) flags |=CAR;\
- else flags |=NEG
- #define CPX(y) \
- tbyte=ByteAt(y()); flags &=~(CAR+ZER+NEG);\
- if (x==tbyte) flags |=CAR+ZER;\
- else if (x>tbyte) flags |=CAR;\
- else flags |=NEG
- #define CMP(x) \
- tbyte=ByteAt(x()); flags &=~(CAR+ZER+NEG);\
- if (a==tbyte) flags |=CAR+ZER;\
- else if (a>tbyte) flags |=CAR;\
- else flags |=NEG
- #define SBC(x) \
- addr=ByteAt(x());\
- if (flags&DEC) {\
- addr = bcd2dec[a]-bcd2dec[addr]-((flags&CAR)?0:1);\
- flags &= ~(CAR+ZER+NEG+OVF);\
- if (addr==0) flags |=ZER+CAR;\
- else if (((int)addr)>0) flags |=CAR;\
- else {flags|=NEG; addr +=100;}\
- a=dec2bcd[addr];}\
- else {\
- addr = a-addr-((flags&CAR)?0:1);\
- flags &=~(CAR+ZER+OVF+NEG);\
- if (addr==0) flags |=ZER+CAR;\
- else if (((int)addr)>0) flags |=CAR;\
- else flags|=OVF;\
- flags |=addr&128;\
- a=addr&255;}
- #define DECR(x) \
- addr=x(); tbyte=ByteAt(addr);\
- flags &=~(ZER+NEG);\
- if (--tbyte) flags |=tbyte&128; else flags|=ZER;\
- RAM[addr] = tbyte; \
- if (addr==1) \
- if (tbyte!=oldMemoryMap) \
- { \
- oldMemoryMap=tbyte; \
- SetUpMemoryMap(); \
- }
- #define INCR(x) \
- addr=x(); tbyte=ByteAt(addr);\
- flags &=~(ZER+NEG);\
- if (++tbyte) flags |=tbyte&128; else flags|=ZER;\
- RAM[addr] = tbyte; \
- if (addr==1) \
- if (tbyte!=oldMemoryMap) \
- { \
- oldMemoryMap=tbyte; \
- SetUpMemoryMap(); \
- }
- #define LDA(x) a=ByteAt(x()); FlagsNZ(a)
- #define LDY(x) y=ByteAt(x()); FlagsNZ(y)
- #define LDX(y) x=ByteAt(y()); FlagsNZ(x)
-
- /* UNDOCUMENTED OPCODES */
- #define AAX(y) \
- addr=y(); tbyte=a&x; RAM[addr]=tbyte;FlagsNZ(tbyte);
- #define AMA() \
- tbyte=ImmediateByte(); a=a&tbyte&0x11; FlagsNZ(a);
- #define ANA() \
- tbyte=ImmediateByte(); a=a&tbyte;FlagsNZ(a);\
- if(a&128) flags|=CAR;else flags&=~CAR;
- #define AXM() \
- a=a&x;\
- addr=ImmediateByte();\
- if (flags&DEC) {\
- addr = bcd2dec[a]-bcd2dec[addr]-((flags&CAR)?0:1);\
- flags &= ~(CAR+ZER+NEG+OVF);\
- if (addr==0) flags |=ZER+CAR;\
- else if (((int)addr)>0) flags |=CAR;\
- else {flags|=NEG; addr +=100;}\
- a=dec2bcd[addr];}\
- else {\
- addr = a-addr-((flags&CAR)?0:1);\
- flags &=~(CAR+ZER+OVF+NEG);\
- if (addr==0) flags |=ZER+CAR;\
- else if (((int)addr)>0) flags |=CAR;\
- else flags|=OVF;\
- flags |=addr&128;\
- a=addr&255;}
- #define AXS(y) \
- sp=a&x;FlagsNZ(sp);\
- RAM[y()]=sp&0x11;
- #define CRS()
- #define DCP(x) \
- addr=x(); tbyte=RAM[addr]=ByteAt(addr)-1; \
- flags &=~(CAR+ZER+NEG);\
- if ((a-tbyte)==tbyte) flags |=CAR+ZER;\
- else if ((a-tbyte)>tbyte) flags |=CAR;\
- else flags |=NEG
- #define ISB(x) \
- addr=x(); tbyte=RAM[addr]=ByteAt(addr)-1; \
- addr=tbyte;\
- if (flags&DEC) {\
- addr = bcd2dec[a]-bcd2dec[addr]-((flags&CAR)?0:1);\
- flags &= ~(CAR+ZER+NEG+OVF);\
- if (addr==0) flags |=ZER+CAR;\
- else if (((int)addr)>0) flags |=CAR;\
- else {flags|=NEG; addr +=100;}\
- a=dec2bcd[addr];}\
- else {\
- addr = a-addr-((flags&CAR)?0:1);\
- flags &=~(CAR+ZER+OVF+NEG);\
- if (addr==0) flags |=ZER+CAR;\
- else if (((int)addr)>0) flags |=CAR;\
- else flags|=OVF;\
- flags |=addr&128;\
- a=addr&255;}
- #define LAN(x) \
- addr=x();\
- tbyte=ByteAt(addr);\
- if (flags&CAR) {\
- if (tbyte&128);\
- else flags &=~CAR;\
- tbyte=(tbyte<<1)|1; }\
- else {\
- if (tbyte&128) flags|=CAR;\
- tbyte=tbyte<<1; }\
- a&=tbyte; FlagsNZ(a);
- #define LAS(y) \
- a=x=sp=ByteAt(y()); FlagsNZ(a);
- #define LAX(y) \
- a=x=ByteAt(y());FlagsNZ(a);
- #define LOR(x) \
- addr=x(); tbyte=ByteAt(addr);if (tbyte&1) flags|=CAR;else flags&=~CAR;\
- tbyte=tbyte>>1; RAM[addr]=tbyte; a|=tbyte; FlagsNZ(a);
- #define RAD(x) \
- addr=x();\
- tbyte=ByteAt(addr);\
- if (flags&CAR) {\
- if (tbyte&128);\
- else flags &=~CAR;\
- tbyte=(tbyte<<1)|1; }\
- else {\
- if (tbyte&128) flags|=CAR;\
- tbyte=tbyte<<1; }\
- addr=tbyte;\
- if (flags&DEC) {\
- addr = bcd2dec[addr]+bcd2dec[a]+((flags&CAR)?1:0);\
- flags &= ~(CAR+OVF+NEG+ZER);\
- if (addr>99) {flags|=CAR+OVF;addr -=100;}\
- if (addr==0) flags|=ZER; else flags |=addr&128;\
- a=dec2bcd[addr];}\
- else {\
- addr += a+((flags&CAR)?1:0);\
- flags &= ~(CAR+OVF+NEG+ZER);\
- if (addr>255) {flags|=OVF+CAR; addr &=255;}\
- if (addr==0) flags|=ZER; else flags |=addr&128;\
- a=addr;}
- #define RMAM() \
- a&=ImmediateByte();\
- if(flags&CAR){if(a&1); else flags&=~CAR;a=(a>>1)|128;}\
- else{if(a&1) flags|=CAR;a=a>>1;}\
- FlagsNZ(a);
- #define RBM() \
- a&=ImmediateByte();\
- if(a&1)flags|=CAR;else flags&=~CAR;a=a>>1;FlagsNZ(a);
- #define REO(x) /* Her name is Reo, and she dances on the sands...sorry*/ \
- addr=x();tbyte=ByteAt(addr);if(tbyte&128)flags|=CAR;else flags&=~CAR;\
- tbyte=RAM[addr]=tbyte<<1;a^=tbyte;FlagsNZ(a);
- #define SKP(x) \
- pc+=x;
- #define TEA(y) \
- tbyte=RAM[y()]=a&x&ByteAt(pc+1);FlagsNZ(tbyte);
- #define TEX(y) \
- tbyte=RAM[y()]=x&ByteAt(pc+1);FlagsNZ(tbyte);
- #define TEY(x) \
- tbyte=RAM[x()]=y&ByteAt(pc+1);FlagsNZ(tbyte);
- #define XMA() \
- a|=x&ImmediateByte();FlagsNZ(a);